package com.njuse.jvmfinal.Instruction;

import java.nio.ByteBuffer;

import com.njuse.jvmfinal.runtimestructure.Jframe;

public class IF_ICMPLE extends Instruction {
	private int  offset;
	
	public  void readindex(ByteBuffer reader) {
		this.offset=(int)reader.getShort();
	}
	
	public  void execute(Jframe frame) {
		int top=frame.getStacktop();
		Object[] stack=frame.getManagestack();
		int value2=(int) stack[top-1];
		int value1=(int) stack[top-2];
		frame.setStacktop(top-2);
		if (value1<=value2) {
			frame.setPc(frame.getPc()-3+offset);
		}
	}
}
